package com.sky.verify;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class CheckPasswordServlet extends HttpServlet{
	
	  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		        response.setContentType("text/html;charset=utf-8");
				//校验邮箱ajax(1.邮箱是否为空, 2.邮箱格式是否正确，,3.邮箱是否已经被注册)
				//1.获取请求参数
		        String password = request.getParameter("password");
				System.out.println("==password="+password);				
				//2.业务逻辑处理
				String result="";
				//2.1.用户名是否为空,
				if("".equals(password)||null==password){
					result="密码不能为空";
				}else if(!password.matches("^\\S{6,}$")){
					//2.2 用户名长度，使用正则表达式
					result="密码过短,至少六位";
				 }else {
					//2.3.用户名是否已经被注册
					result="OK";			 
				 }
				//3.处理结果，响应给页面
				response.getWriter().write(result);
			}

			public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
				doGet(request, response);
			}

			
	}

